<?php

$revisions = $db->fetchCol("SELECT r.id FROM blog_posts p LEFT JOIN blog_posts_revisions r ON p.id=r.post_id WHERE site_id=? AND p.id=? AND r.id>p.revision_id", array($site['id'], $_REQUEST['id']));

if (count($revisions)) {
	$revisions = join(',', $revisions);
	$db->query("DELETE FROM blog_posts_revisions WHERE id IN ({$revisions})");
}

header('Content-type: application/json');
echo json_encode(array('id' => $_REQUEST['id']));